<template>
    <a-config-provider :locale="locale">
        <div id="app">
            <router-view v-if="isRouterAlive"/>
        </div>
    </a-config-provider>
</template>
<script>
import zhCN from 'ant-design-vue/lib/locale-provider/zh_CN'
import enquireScreen from '@/utils/device'
export default {
    provide(){
        return{
            reload: this.reload
        }
    },
    data () {
        return {
            locale: zhCN,
            isRouterAlive: true
        }
    },
    mounted(){
        if (!!window.ActiveXObject || "ActiveXObject" in window){
            alert('请用火狐、360极速模式、谷歌浏览器访问')
            return;
        } else {
            console.log('no')
        }
    },
    created () {
        // alert('213123123123123123')
        let that = this
        enquireScreen(deviceType => {
            // tablet
            if (deviceType === 0) {
                that.$store.commit('TOGGLE_DEVICE', 'mobile')
                that.$store.dispatch('setSidebar', false)
            }
            // mobile
            else if (deviceType === 1) {
                that.$store.commit('TOGGLE_DEVICE', 'mobile')
                that.$store.dispatch('setSidebar', false)
            }
            else {
                that.$store.commit('TOGGLE_DEVICE', 'desktop')
                that.$store.dispatch('setSidebar', true)
            }
        })
    },
    methods:{
        reload(){
            this.isRouterAlive = false
            this.$nextTick(function(){
                this.isRouterAlive = true
            })
        }
    }
}
</script>
<style lang="less">
#app {
    height: 100%;
}
* {
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 16px;
}
.pointer {
    cursor: pointer;
}
.screenModal {
    &.fullscreen {
        .ant-modal {
            width: 100% !important;
            top: 0 !important;
            height: 100% !important;

            .ant-modal-content {
                max-height: 100% !important;
                height: 100% !important;
            }
        }
    }
}
</style>